

<script setup>
	import Icon from '@/common/components/Icon/index.vue';
	import Tab from '@/common/components/Tab/index.vue';
	import Classification from '@/components/Classification/index.vue'
	import {ref,onMounted} from 'vue';
	
	const bookShelfList = ref([]);
	const categorySelected = ref(0);
	// 选择不同的分类
	const categoryId = ref(null);
	
	// 切换选项卡
	function tabEvent(e){
		categorySelected.value = e.index;
		categoryId.value = bookShelfList.value[categorySelected.value]?.list[0]?.id
	}
	// 选择不同分类
	function categorySeleted(id){
		categoryId.value = id;
	}
	onMounted(()=>{
		bookShelfList.value.push({
			id:"1",
			tabName:"书架",
			list:[]
		},{
			id:"2",
			tabName:"浏览历史",
			list:[]
			
		},{
			id:"3",
			tabName:"圈子",
			list:[]
			
		},)
	})
	
</script>
<template>
	<view class="booksheif__container container">
		<!-- 导航栏 -->
		<view class="home__top">
			<!-- 分类列表 -->
			<Tab :list="bookShelfList" v-if="bookShelfList.length>0" @tabEvent="tabEvent" normalFontSize="36rpx"  boldFontSize="50rpx">
				<template #top-right="obj">
					<view class="search__btn">
						<Icon class="search__svg" href="sandian" size="60rpx"/>
					</view>
				</template>
				<template #[`tab-${index}`]="obj" v-for="(item,index) in bookShelfList">
					<!-- 筛选组件 -->
					<view class="sifting">
						<view class="sifting__top">
							<view class="sifting__top__name">名称{{categorySelected}}</view>
							<view class="sifting__top__utils">
								<cover-view class="utils__name">筛选</cover-view>
								<cover-view class="utils__name">编辑</cover-view>
							</view>
						</view>
						<view class="sifting__list" :class="[{'status-flex':categorySelected==1}]">
							<!-- 正常状态 -->
							<view class="book" :class="[{'status-flex':categorySelected==1}]" v-for="i in 10">
								<!-- 图片  完结 断更 连载中 -->
								<view class="book__top">
									<view class="book__top__icon">完结</view>
									<cover-image class="book__top__img" src="/static/logo.png"></cover-image>
								</view>
								<view class="book__main">
									<!-- 书名称 -->
									<view class="book__name lineTow">xx章未读章未读章未读章未读章未读</view>
									<!-- 章节数 -->
									<view class="book__utils">123章未读</view>
								</view>
							</view>
						</view>
					</view>
				</template>
			</Tab> 
		</view>
	</view>
</template>
<style lang="scss" scoped>
	.booksheif__container{
			display: flex;
			flex-direction: column;
			gap: 30rpx;
			background-color: #fff;
			// padding: 0;
			padding-left: 0;
			padding-right: 0;
			
	}
	::v-deep .tab__navigation{
		padding: 0 20rpx;
	}
	.sifting{
		display: flex;
		flex-direction: column;
		gap: 20rpx;
		padding: 20rpx 20rpx 0;
		
		&__top{
			display: flex;
			align-items: center;
			justify-content: space-between;
			font-size: 30rpx;
			&__name{
				font-weight: bold;
			}
			&__utils{
				font-weight: bold;
				display: flex;
				align-items: center;
				.utils__name{
					padding: 0 20rpx;
				}
				>:first-child {
					border-right: 4rpx solid #ccc;
				}
			}
		}
	
		&__list{
			display: grid;
			grid-template-columns: repeat(3,1fr);
			gap: 50rpx;
			padding: 10rpx 0;
			&.status-flex{
				display: flex;
				flex-direction: column;
			}
		}
	}
	:has(.book.status-flex) .book .book__main{
		gap: 40rpx;
		// background-color: red;
	}
	.book{
		display: flex;
		flex-direction: column;
		gap: 16rpx;
		
		&.status-flex{
			flex-direction: row;
			align-items: center;
		}
		.book__top{
			position: relative;
			&__icon{
				position: absolute;
				top: 10rpx;
				right: 10rpx;
				background-color: #252621;
				color: white;
				padding: 4rpx 6rpx;
			}
			&__img{
				width: 100%;
				// height: 100%;
				aspect-ratio: 1/1.3;
			}
		}
		&__main{
			display: flex;
			flex-direction: column;
			gap: 20rpx;
			
		}
		&__name{
			font-weight: bold;
			width: 90%;
			font-size: 32rpx;
			line-height: 32rpx;
		}
		&__utils{
			color: #9d9d9d;
			font-size: 26rpx;
		}
	}
</style>
